import 'package:flutter/material.dart';
import 'package:kiomax/pages/location/location_select_page.dart';

import '../../config/color_config.dart';

TitleWidget({
  bool isHome = false,
  required BuildContext context,
  required GlobalKey<ScaffoldState> scaffoldKey,
  List<Widget>? actions,
}) {
  return AppBar(
    backgroundColor: Colors.white,
    elevation: 0,
    leadingWidth: 77,
    leading: IconButton(
      icon: Icon(isHome?Icons.add_home : Icons.menu, size: 24, color: const Color(0xFF333333)),
      padding: const EdgeInsets.only(left: 0),
      onPressed: () {
        if(!isHome) {
          scaffoldKey.currentState?.openDrawer();
        }else{
          Navigator.popUntil(context, (route) => route.settings.name == '/home');
        }
      },
    ),
    actions: [
      Padding(
        padding: const EdgeInsets.only(right: 24.0),
        child: Row(
          mainAxisSize: MainAxisSize.min, // 只占自身内容宽度
          crossAxisAlignment: CrossAxisAlignment.center, // 垂直方向居中对齐
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.end, // 右对齐文字
              mainAxisAlignment: MainAxisAlignment.center, // 垂直方向居中
              children: const [
                Text(
                  'Welcome!',
                  style: TextStyle(
                    color: Color(0xFF333333),
                    fontSize: 14,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                Text(
                  'operator@gvarcade.com',
                  style: TextStyle(
                    color: Color(0xFF999999),
                    fontSize: 14,
                  ),
                ),
              ],
            ),
            const SizedBox(width: 12),
            const CircleAvatar(
              radius: 16,
              backgroundColor: Color(0xFFF5F5F5),
              child: Icon(
                Icons.person,
                size: 20,
                color: Color(0xFF666666),
              ),
            ),
          ],
        ),
      ),
    ],
  );
}
